import os
# -*- coding:utf-8 -*-
import os
import sys
from loguru import logger

pythonPath = os.path.join(os.path.dirname(__file__), '..')
if pythonPath not in sys.path:
    sys.path.append(pythonPath)
logger.add('./logs/info.log', format="{time:YYYY-MM-DD HH:mm:ss.SSS}|{level}|{message}")


class Config:
    """
    配置文件
    """
    PYTHON_PORT = 6001
    API_INDEX = "/api/nlp/"
    APP_SESSION_COOKIE_NAME = 'baidu'
    TIME = 86400
    APP_SECRET_KEY = 'baidu'
    TOKEN_LIST = "314b468b-e62b-4d4a-9212-aa665badb3c3"
    DATA_HOME = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'data'))
    if not os.path.exists(DATA_HOME):
        os.mkdir(DATA_HOME)
    ISGPU = False
    UNKNOW='你好，这个问题小云暂时不明白'
    kg = os.path.join(DATA_HOME, 'kg.json')
    threshold = 0.6
    sentences_path=os.path.join(DATA_HOME, 'sentences.txt')


for k in os.environ:
    if k in Config.__dict__:
        logger.info('use environ var:' + str(k) + ',' + str(os.environ.get(k)))
        setattr(Config, k, os.environ.get(k))
CONFIG = Config()
for k in os.environ:
    if k in CONFIG.__dict__:
        logger.info('use environ var:' + str(k) + ',' + str(os.environ.get(k)))
        CONFIG.__dict__[k] = os.environ.get(k)
